<template>
	<view>
		<view style="width: 700rpx;margin:20rpx auto;">
			<u-image :src="info.cover" width="700" height="400" border-radius="20"></u-image>
		</view>
		<view class="u-padding-30">
			<view>{{info.goodsName}}</view>
			<view class="$u-type-info u-margin-top-20">
				<u-parse :html="info.detail"></u-parse>
			</view>
			
		</view>
		
		<view class="u-flex  u-row-between  bottomFixs ">
			<view >
				
				<view style="font-size: 26rpx;color: #007AFF;font-weight: bold;">{{info.integral}}积分<text
						v-if="Number(info.price)>0"> +{{info.price}}元</text> </view>
			</view>
			<u-button size="mini" type="primary" shape="circle" @click="buy">立即购买</u-button>
		</view>
		
	</view>
</template>

<script>
	export default{
		data(){
			return{
                 id:''	,
							 info:{
								 
							 }
			}
		},
		onLoad(options){
			if(options.id){
				this.id=options.id
			}
			this.jiazai()
		},
		methods:{
			jiazai(){
				this.$u.post('/api/index/goodsDetail', {
					goods_id: this.id,
				}).then(res => {
				   this.info=res;
				}).catch(err => {
							
				})
			},
			buy() {
				// goodsType == 2 需要收货
		
					this.$u.post('/api/indent/affirm', {
						goods_id:this.id,
					    num: 1,
					}).then(res => {
			            uni.navigateTo({
			            	url:"../../pages/sure_book/index?info="+encodeURIComponent(JSON.stringify(res))
			            })
					}).catch(err => {
								
					})
				
				
			},
		}
	}
</script>

<style>
	.bottomFixs{
		border-top: 1rpx solid #f1f1f1;
		width: 100%;
		position: fixed;
		bottom: 0;
		padding: 20rpx;
	}
</style>
